//transmit support for std::vector
//$Id: transmit_vector.h 137 2009-09-02 15:11:09Z Oleg.Bulychov $
#pragma once
#ifndef TRANSMIT_VECTOR_H
#define TRANSMIT_VECTOR_H

#include <vector>
#include "src/heo/include/transmit.h"
//__________________________________________________________________________________
//__________________________________________________________________________________
template<class X, class V>
struct transmit_handler<std::vector<X>, V>
{
    static void visit(std::vector<X>& vec, V& v)
    {
        visit(vec, v, meta::int2type<V::transmit_tag>());
    }

    static void visit(std::vector<X>& vec, V& bcast, meta::int2type<BCAST_TAG>)
    {
        if (bcast.is_Root())
        {
            visit(vec, bcast, meta::int2type<SEND_TAG>());
        }
        else
        {
            visit(vec, bcast, meta::int2type<RECV_TAG>());
        }
    }

    static void visit(std::vector<X>& vec, V& send, meta::int2type<SEND_TAG>)
    {
        size_t cb = vec.size();
        send << cb;
        if (cb > 0)
            send.visit_Array(&vec[0], cb, "", 0);
    }

    static void visit(std::vector<X>& vec, V& recv, meta::int2type<RECV_TAG>)
    {
        size_t cb = 0;
        recv >> cb;
        vec.resize(cb);
        if (cb > 0)
            recv.visit_Array(&vec[0], cb, "", 0);
    }
};
//__________________________________________________________________________________
//__________________________________________________________________________________

#endif
//EOF!
